
<%@ page import="org.springframework.context.support.MessageSourceAccessor" %>
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils" %>
<%@ page import="com.gph.saviorframework.OaConstants" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page isELIgnored="false" %>
<%@ include file="/include/taglibs.jsp" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
    pageContext.setAttribute("base", basePath);
    MessageSourceAccessor messages = WebApplicationContextUtils.getWebApplicationContext(getServletConfig().getServletContext()).getBean(MessageSourceAccessor.class);
    String basePath2 = request.getScheme() + "://" + messages.getMessage("serverip") + ":" + request.getServerPort();
    String content = basePath2+request.getContextPath()+"/"+ OaConstants.APP_PATH+"/app-update/download-file-lasted";
    pageContext.setAttribute("content", content);
%>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <!-- <meta name=”renderer” content=”webkit|ie-comp|ie-stand” /> -->
    <%--<meta name="renderer" content="webkit"/>--%>
    <title>中国科学院海洋所“科学”号用户登录</title>
    <meta name="description" content="User login page"/>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <%-- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>--%>
    <base href="<%=basePath%>"/>
    <%--<meta http-equiv="pragma" content="no-cache"/>
    <meta http-equiv="cache-control" content="no-cache"/>
    <meta http-equiv="expires" content="0"/>
    <meta http-equiv="keywords" content=""/>--%>
    <%--<meta http-equiv="description" content="青岛工业软件研究所CSCW"/>--%>
    <link type="text/css" rel="stylesheet" href="${ctx}/assets/admin/LingUI/login/css/login.css">
    <link rel="stylesheet" href="${ctx}/assets/admin/LingUI/login/css/style.css">
    <script src="${ctx}/assets/admin/LingUI/js/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script src="${ctx}/assets/admin/LingUI/js/jquery.backstretch.min.js"></script>
    <script src="${ctx}/assets/admin/LingUI/js/jquery.placeholder.min.js"></script>
    <script type="text/javascript" src="${ctx}/js/jquery.qrcode.js"></script>
    <script type="text/javascript" src="${ctx}/js/qrcode.js"></script>
    <!--[if lte IE 8]>
    <style>
        body {
            overflow-x: hidden;
        }

       /* input {
            line-height: 43px;
        }*/
    </style>
  <!-- <script type='text/javascript'>
        var code ; //在全局定义验证码
        function createCode(){
            code = "";
            var codeLength = 4;//验证码的长度
            var checkCode = document.getElementById("code");
            var random = new Array(0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R',
                    'S','T','U','V','W','X','Y','Z');//随机数
            for(var i = 0; i < codeLength; i++) {//循环操作
                var index = Math.floor(Math.random()*36);//取得随机数的索引（0~35）
                code += random[index];//根据索引取得随机数加到code上
            }
            checkCode.value = code;//把code值赋给验证码
        }
        //校验验证码
        function validate(){
            var inputCode = document.getElementById("input").value.toUpperCase(); //取得输入的验证码并转化为大写
            if(inputCode.length <= 0) { //若输入的验证码长度为0
                alert("请输入验证码！"); //则弹出请输入验证码
            }else if(inputCode != code ) { //若输入的验证码与产生的验证码不一致时
                alert("验证码输入错误！@_@"); //则弹出验证码输入错误
                createCode();//刷新验证码
                document.getElementById("input").value = "";//清空文本框
            }else { //输入正确时
                alert("合格！^-^");
            }
        }
    </script>-->
    <![endif]-->
</head>
<body>
    <div class="bg">
        <div class="login-con">

            <div class="logo">
                <img src="${ctx}/images/logo.png" alt="">
            </div>
            <h1 style="margin-top:40px;">用户登录</h1>
            <form class="log" id="form" name="form" <%--action="${base}/login?loginType=bu"--%> method="post" onsubmit="return check();">
                <div class="user">
                    <input type="text" name="username" id="username" class="username" placeholder="证件号码" value="">
                </div>
                <div class="passw">
                    <input type="password" name="password" id="password" class="password" placeholder="请输入密码" value="">
                </div>
                <div class="yanz">
                    <input type="text" id="verificationCode" name="verificationCode" class="yanzhengma" placeholder="输入验证码的计算结果" value="" autocomplete="off">
                    <img class="ycode" id="captchaImage" src="${ctx}/genVerCode" onclick="changeCode()" alt="换一张"  style="cursor:pointer">
                </div>
               <%-- <div class="yanz">
                    <input type = "text" class="yanzhengma" id = "input" placeholder="请输入验证码"/>
                    <input type="button" id="code" class="ycode" onclick="createCode()"  title='点击更换验证码' value="123"/>
                </div>--%>

                <div class="passw">
                    <input type="checkbox" id="rememberMe" name="rememberMe" value="true" class="check"><span id="rem">记住我</span>
                    <a href="${ctx}/forgetpass" style="color:#55afed;text-decoration:none;"><span id="forgetp">忘记密码</span></a>
                </div>
                <input type="hidden" name="openid" value="">
                <div style="float: left; margin-top: 10px;width: 100%;text-align: left;margin-left:40px;">
                    <c:if test="${!empty(error)}">
                        <i class="ace-icon fa fa-times-circle"></i>
                        <span style="color: red;padding-left:250px;">${error}</span>
                    </c:if>
                </div>
                <div class="btn_b">
                    <button type="button"  onclick="submitReq();">登 &nbsp 录</button>
                </div>
                <div class="btn_b">
                    <button type="button"  onclick="doRegister1();" class="btn_signin">注 &nbsp 册</button>
                </div>
            </form>

</div>

    </div>
    <p style="position: relative;bottom: 20px;left:0px;font-weight: 600">友情提示：推荐使用谷歌，火狐及IE8以上版本浏览器。</p>
    <script type="text/javascript">
        $(function(){
            //$('#androidm').qrcode("");
        });
        function doRegister1(){
            window.location.href="${ctx}/${frameworkPath}/user/register";     //在同当前窗口中打开窗口
        }
        var login = "${base}";
        function submitReq() {
            var upname = $("#username").val();
            var pwd= $("#password").val();
            var rememberMe = document.getElementsByName("rememberMe");
            addCookie("remember", rememberMe[0].checked, 7, "/");
            if (rememberMe[0].checked) {
                addCookie("username", base64_encode(utf16to8(upname)), 7, "/");
                //addCookie("password", base64_encode(utf16to8(pwd)), 7, "/");
            } else {
                deleteCookie("username", "/");
                //deleteCookie("password", "/");
            }
            /*             $.ajax({type:'POST','/admin/logon.do',data:{KEYDATA:code,tm:new Date().getTime()},
             dataType:'json',success:function(data, textStatus) {
             dialogloadingClose();
             var result=data.result;
             if ("success" != result) {  //如果登录不成功，则再次刷新验证码
             dialogloadingClose();
             clearLoginForm();//清除信息
             loginAlert(result);
             }else{
             window.location.href=jypath+"/backstage/index";
             }
             }
             }); */
            $("#form").submit();
        }

        /**添加设置cookie**/
        function addCookie(name, value, days, path) {
            //username-password-天数-路径
            var name = escape(name);
            var value = escape(value);
            var expires = new Date();
            expires.setTime(expires.getTime() + days * 3600000 * 24);
            //path=/，表示cookie能在整个网站下使用，path=/temp，表示cookie只能在temp目录下使用
            path = path == "" ? "" : ";path=" + path;
            //GMT(Greenwich Mean Time)是格林尼治平时，现在的标准时间，协调世界时是UTC
            //参数days只能是数字型
            var _expires = (typeof days) == "string" ? "" : ";expires=" + expires.toUTCString();
            document.cookie = name + "=" + value + _expires + path;
        }
        function quxiao() {
            $("#username").val('');
            $("#password").val("");
            $("#captcha").val('');
        }
    </script>
    <script type="text/javascript">

       /* *实现功能，保存用户的登录信息到cookie中。当登录页面被打开时，就查询cookie*
         if (isBrowserErr()) {
         location.href = "${base}/browserr.jsp";
         }*/
        var logname = "";
        window.onload = function () {
            var remember = getCookieValue("remember");
            if (remember == "true") {
                document.getElementById("rememberMe").checked = true;
                var usernameValue = getCookieValue("username");
                if (usernameValue != "") {
                    $("#username").val(utf8to16(base64_decode(usernameValue)));
                }
                var pwdValue = getCookieValue("password");
                if (pwdValue != "") {
                    $("#password").val(utf8to16(base64_decode(pwdValue)));
                }
                $('input, textarea').placeholder();
            } else {
                $('input, textarea').placeholder();
            }
        }
        /**获取cookie的值，根据cookie的键获取值**/
        function getCookieValue(name) {
            //用处理字符串的方式查找到key对应value
            var name = escape(name);
            //读cookie属性，这将返回文档的所有cookie
            var allcookies = document.cookie;
            //查找名为name的cookie的开始位置
            name += "=";
            var pos = allcookies.indexOf(name);
            //如果找到了具有该名字的cookie，那么提取并使用它的值
            //如果pos值为-1则说明搜索"version="失败
            if (pos != -1) {
                //cookie值开始的位置
                var start = pos + name.length;
                //从cookie值开始的位置起搜索第一个";"的位置,即cookie值结尾的位置
                var end = allcookies.indexOf(";", start);
                //如果end值为-1说明cookie列表里只有一个cookie
                if (end == -1) end = allcookies.length;
                //提取cookie的值
                var value = allcookies.substring(start, end);
                //对它解码
                return (value);
            } else {  //搜索失败，返回空字符串
                return "";
            }
        }
        /**根据cookie的键，删除cookie，其实就是设置其失效**/
        function deleteCookie(name, path) {
            var name = escape(name);
            var expires = new Date(0);
            path = path == "" ? "" : ";path=" + path;
            document.cookie = name + "=" + ";expires=" + expires.toUTCString() + path;
        }
        document.onkeydown = keyDownSearch;

        function keyDownSearch(e) {
            // 兼容FF和IE和Opera
            var theEvent = e || window.event;
            var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
            if (code == 13) {
                submitReq();//具体处理函数
                return false;
            }
            return true;
        }

        function check() {
            if ($("#username").val() == "") {
                $("#username").tips({
                    side: 2,
                    msg: '用户名不得为空',
                    bg: '#AE81FF',
                    time: 3
                });
                setTimeout(function () {
                    $("#username").focus();
                }, 100)
                return false;
            } else {
                $("#username").val(jQuery.trim($('#username').val()));
            }

            if ($("#password").val() == "") {
                $("#password").tips({
                    side: 2,
                    msg: '密码不得为空',
                    bg: '#AE81FF',
                    time: 3
                });
                $("#password").focus();
                //document.getElementById("password").focus();
                return false;
            }

            if ($("#captcha").val() == "") {
                $("#captcha").tips({
                    side: 2,
                    msg: '验证码不得为空',
                    bg: '#AE81FF',
                    time: 3
                });
                $("#captcha").focus();
                return false;
            }

            $("#username").tips({
                side: 1,
                msg: '正在登录 , 请稍后 ...',
                bg: '#68B500',
                time: 1000
            });
            return true;
        }

        //刷新验证码
        function changeCode(){
            $("#captchaImage").attr("src", "${ctx}/genVerCode?timestamp=" + (new Date()).valueOf());
        }
    </script>
    <script>
        //TOCMAT重启之后 点击左侧列表跳转登录首页
        if (window != top) {
            top.location.href = location.href;
        }
    </script>
    <script type="text/javascript" src="${ctx}/assets/admin/LingUI/login/js/jquery.tips.js"></script>
    <script type="text/javascript" src="${ctx}/assets/admin/LingUI/login/js/base64.js"></script>
    <script type="text/javascript">
        $(function () {
            $.backstretch("${ctx}/assets/admin/LingUI/login/images/beijing.png");
        });
    </script>
</body>
</html>
